package com.service;

import com.dao.UserRepository;
import com.po.Activity;
import com.po.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class UserServiceImpl implements UserService{
    @Autowired
    private UserRepository userRepository;

    @Override
    public User checkUserByPhone(String phone) {
        User user = userRepository.findByPhone(phone);
        return user;
    }

    @Override
    public User checkUserByPP(String phone, String password) {
        User user = userRepository.findByPhoneAndPassword(phone,password);
        return user;
    }

    @Override
    public User saveUser(User user) {
        return userRepository.save(user);
    }

    @Override
    public List<User> find() {
        return userRepository.findAll();
    }

    @Override
    public int findUserSize() {
        return userRepository.findAll().size();
    }

    @Override
    public List<User> findAll(int i) {
        return userRepository.findAllByState(i);
    }

    @Override
    public User findInfo(Long id) {
        return userRepository.findById(id).get();
    }



}
